package com.example.shrio;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.example.admin.entity.CommonUser;
import com.example.admin.entity.SysUser;

/**
 * 获取当前登陆对象
 *
 * @author wangkai
 * @date: 2019年6月3日 下午2:56:48
 */
public class CurrentUser {

    /**
     * 返回Subject
     *
     * @return
     */
    public static Subject getSubject() {
        return SecurityUtils.getSubject();
    }

    /**
     * 返回session
     *
     * @return
     */
    public static Session getSession() {
        return getSubject().getSession();
    }

    /**
     * 当前用户
     *
     * @return
     */
    public static SysUser getAdminUser() {
        SysUser user = (SysUser) getSubject().getPrincipal();
        return user;
    }

    public static CommonUser getCommonUser() {
        CommonUser user = (CommonUser) getSubject().getPrincipal();
        return user;
    }


    /**
     * 退出当前账号
     */
    public static void logout() {

        getSubject().logout();
    }







}
